home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / miscellaneous / example1.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  8KB  |  284 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE)           Amiga C Club (ACC) */
  4. /* --------------------------           ------------------ */
  5. /*                                                         */
  6. /* Manual:  AmigaDOS                    Amiga C Club       */
  7. /* Chapter: Miscellaneous               Tulevagen 22       */
  8. /* File:    Example1.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    93-09-26                                       */
  11. /* Version: 1.2                                            */
  12. /*                                                         */
  13. /*   Copyright 1993, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example demonstrates how to use the IoErr() function. */
  21. /* It contains a simple but rather useful function which will */
  22. /* try to give the user some more information about the last  */
  23. /* dos error. Good for debugging!                             */
  24.  
  25.  
  26.  
  27. /* Include the dos library definitions: */
  28. #include <dos/dos.h>
  29.  
  30. /* Now we include the necessary function prototype files:         */
  31. #include <clib/dos_protos.h>       /* General dos functions...    */
  32. #include <clib/exec_protos.h>      /* System functions...         */
  33. #include <stdio.h>                 /* Std functions [printf()...] */
  34. #include <stdlib.h>                /* Std functions [exit()...]   */
  35.  
  36.  
  37.  
  38. /* Set name and version number: */
  39. UBYTE *version = "$VER: AmigaDOS/Miscellaneous/Example1 1.2";
  40.  
  41.  
  42.  
  43. /* Declared our own functions: */
  44.  
  45. /* Our main function: */
  46. int main( int argc, char *argv[] );
  47.  
  48. /* Prints some information about the error: */
  49. void explain_error( void );
  50.  
  51.  
  52.  
  53. /* Main function: */
  54.  
  55. int main( int argc, char *argv[] )
  56. {
  57.   /* Well, this example does not do very much for the moment.  */
  58.   /* However, you can copy the function "explain_error()" into */
  59.   /* your own programs for debugging.                          */
  60.   printf( "May the bugs be few...\n" );
  61.  
  62.   /* The End! */
  63.   exit( 0 );
  64. }
  65.  
  66.  
  67.  
  68. /* This function will collect the global error code and */
  69. /* print some information about the last dos error:     */
  70.  
  71. void explain_error( void )
  72. {
  73.   /* Store the error value here: */
  74.   LONG error_code;
  75.  
  76.  
  77.  
  78.   /* Collect the global error code: */
  79.   error_code = IoErr();
  80.  
  81.   /* Print the error code: */
  82.   printf( "Error code: %d - ", error_code );
  83.  
  84.   /* Examine the error code: */  
  85.   switch( error_code )
  86.   {
  87.     case ERROR_NO_FREE_STORE:
  88.       printf( "Out of memory!\n" );
  89.       break;
  90.  
  91.     case ERROR_TASK_TABLE_FULL: 
  92.       printf( "To many processes running!\n" );
  93.       break;
  94.  
  95.     case ERROR_BAD_TEMPLATE: 
  96.       printf( "Incorrect command line template!\n" );
  97.       break;
  98.  
  99.     case ERROR_BAD_NUMBER: 
  100.       printf( "Incorrect number/value!\n" );
  101.       break;
  102.  
  103.     case ERROR_REQUIRED_ARG_MISSING: 
  104.       printf( "Required arguemnt was not set!\n" );
  105.       break;
  106.  
  107.     case ERROR_KEY_NEEDS_ARG: 
  108.       printf( "The argument after the keyword is missing!\n" );
  109.       break;
  110.  
  111.     case ERROR_TOO_MANY_ARGS: 
  112.       printf( "Too many arguments on the command line!\n" );
  113.       break;
  114.  
  115.     case ERROR_UNMATCHED_QUOTES: 
  116.       printf( "Incorrect number of quotations!\n" );
  117.       break;
  118.  
  119.     case ERROR_LINE_TOO_LONG: 
  120.       printf( "Too long command line!\n" );
  121.       break;
  122.  
  123.     case ERROR_FILE_NOT_OBJECT: 
  124.       printf( "The file can not be found and/or executed\n" );
  125.       break;
  126.  
  127.     case ERROR_INVALID_RESIDENT_LIBRARY: 
  128.       printf( "The AmigaDOS library is too old!\n" );
  129.       break;
  130.  
  131.     case ERROR_NO_DEFAULT_DIR: 
  132.       printf( "There does not exist a default directory!\n" );
  133.       break;
  134.  
  135.     case ERROR_OBJECT_IN_USE: 
  136.       printf( "The object is currently used and is locked!\n" );
  137.       break;
  138.  
  139.     case ERROR_OBJECT_EXISTS: 
  140.       printf( "The object already exist and can not be deleted!\n" );
  141.       break;
  142.  
  143.     case ERROR_DIR_NOT_FOUND: 
  144.       printf( "Unknown directory!\n" );
  145.       break;
  146.  
  147.     case ERROR_OBJECT_NOT_FOUND: 
  148.       printf( "Unknown file or device!\n" );
  149.       break;
  150.  
  151.     case ERROR_BAD_STREAM_NAME: 
  152.       printf( "The string contained invalid commands/parameters!\n" );
  153.       break;
  154.  
  155.     case ERROR_OBJECT_TOO_LARGE: 
  156.       printf( "The object is too big!\n" );
  157.       break;
  158.  
  159.     case ERROR_ACTION_NOT_KNOWN: 
  160.       printf( "Impossible command used on a device!\n" );
  161.       break;
  162.  
  163.     case ERROR_INVALID_COMPONENT_NAME: 
  164.       printf( "Too long name or invalid signs used!\n" );
  165.       break;
  166.  
  167.     case ERROR_INVALID_LOCK: 
  168.       printf( "Invalid type of lock used!\n" );
  169.       break;
  170.  
  171.     case ERROR_OBJECT_WRONG_TYPE: 
  172.       printf( "Incorrect object type used!\n" );
  173.       break;
  174.  
  175.     case ERROR_DISK_NOT_VALIDATED: 
  176.       printf( "The disk has not yet been validated or is damaged!\n" );
  177.       break;
  178.  
  179.     case ERROR_DISK_WRITE_PROTECTED: 
  180.       printf( "The disk is write protected!\n" );
  181.       break;
  182.  
  183.     case ERROR_RENAME_ACROSS_DEVICES: 
  184.       printf( "Can not rename an object to another device!\n" );
  185.       break;
  186.  
  187.     case ERROR_DIRECTORY_NOT_EMPTY: 
  188.       printf( "Can not delete the directory since it is not empty!\n" );
  189.       break;
  190.  
  191.     case ERROR_TOO_MANY_LEVELS: 
  192.       printf( "Too many soft links used!\n" );
  193.       break;
  194.  
  195.     case ERROR_DEVICE_NOT_MOUNTED: 
  196.       printf( "Device not available!\n" );
  197.       break;
  198.  
  199.     case ERROR_SEEK_ERROR: 
  200.       printf( "Tried to move the file cursor outside the file!\n" );
  201.       break;
  202.  
  203.     case ERROR_COMMENT_TOO_BIG: 
  204.       printf( "Too long comment used!\n" );
  205.       break;
  206.  
  207.     case ERROR_DISK_FULL: 
  208.       printf( "The disk is full!\n" );
  209.       break;
  210.  
  211.     case ERROR_DELETE_PROTECTED: 
  212.       printf( "The object is protected from being deleted!\n" );
  213.       break;
  214.  
  215.     case ERROR_WRITE_PROTECTED: 
  216.       printf( "The object is protected from being overwritten\n" );
  217.       break;
  218.  
  219.     case ERROR_READ_PROTECTED: 
  220.       printf( "The object is protected from being read!\n" );
  221.       break;
  222.  
  223.     case ERROR_NOT_A_DOS_DISK: 
  224.       printf( "The disk is not of AmigaDOS format!\n" );
  225.       break;
  226.  
  227.     case ERROR_NO_DISK: 
  228.       printf( "No disk in the drive!\n" );
  229.       break;
  230.  
  231.     case ERROR_NO_MORE_ENTRIES: 
  232.       printf( "No more objects in the directory!\n" );
  233.       break;
  234.  
  235.     case ERROR_IS_SOFT_LINK: 
  236.       printf( "Can not do it on a soft link!\n" );
  237.       break;
  238.  
  239.     case ERROR_OBJECT_LINKED: 
  240.       printf( "The object is linked!\n" );
  241.       break;
  242.  
  243.     case ERROR_BAD_HUNK: 
  244.       printf( "Incorect hunk found!\n" );
  245.       break;
  246.  
  247.     case ERROR_NOT_IMPLEMENTED: 
  248.       printf( "The feature has not been implemented yet!\n" );
  249.       break;
  250.  
  251.     case ERROR_RECORD_NOT_LOCKED: 
  252.       printf( "The record was not locked!\n" );
  253.       break;
  254.  
  255.     case ERROR_LOCK_COLLISION: 
  256.       printf( "Two locks collided!\n" );
  257.       break;
  258.  
  259.     case ERROR_LOCK_TIMEOUT: 
  260.       printf( "The time to get the lock has expired!\n" );
  261.       break;
  262.  
  263.     case ERROR_UNLOCK_ERROR: 
  264.       printf( "Problems with unlocking the object!\n" );
  265.       break;
  266.  
  267.     case ERROR_BUFFER_OVERFLOW:
  268.       printf( "Some internal buffer was too small!\n" );
  269.       break;
  270.  
  271.     case ERROR_BREAK:
  272.       printf( "The executin was stopped!\n" );
  273.       break;
  274.  
  275.     case ERROR_NOT_EXECUTABLE:
  276.       printf( "The file is protected from being executed!\n" );
  277.       break;
  278.  
  279.     default:
  280.       printf( "Unknown error reported!\n" );
  281.   }
  282. }
  283.  
  284.